package com.tvunetworks.device.extra.service;

import com.tvunetworks.center.common.model.UpdateTokenCodeParam;
import com.tvunetworks.center.common.util.Result;
import com.tvunetworks.device.extra.model.param.DeletePairParam;

import java.util.List;
import java.util.Map;

/**
 * @author Etan Yang
 * @create: 2021/11/22 13:03
 */

public interface AnywhereService {

    /**
     * create token code by param
     * @param param param
     * @return tokenCode
     */
    Result createTokenCode(UpdateTokenCodeParam param);

    /**
     * token pair confirm
     * @param param param
     * @return result
     */
    Result pairConfirm(Map<String,Object> param);


    /**
     * 根据用户id获取该用户下最新的code码
     * @param userId 用户id
     * @return 用户下最新的code码
     */
    Object getCode(String userId);

    /**
     * 删除anywhere和receiver的配对关系
     * @param param parameter
     * @return 返回结果
     */
    Result deletePair(DeletePairParam param);

    /**
     * 校验token扫码是否成功
     * @param code code码
     * @return 0表示成功，1表示失败，2表示无响应
     */
    int checkPairStatus(String code);

    /**
     * 移除指定receiver下所有的token配对
     *
     * @param receiverId receiver的peerId
     * @param userId     用户的Id
     * @param origin     origin
     */
    void removeAllTokenPair(String receiverId, String userId, int origin);
    /**
     * list tokenIds with receiver paired by rid and origin and token belong of user from token service
     * @param rid receiverId
     * @param userId userId
     * @param origin origin
     * @return Paired tokenIds
     */
    List<String> listTokenIdsByRid(String rid, String userId, int origin);
}
